package top.songxs.gmall.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.common.result.ResultCodeEnum;
import top.songxs.gmall.common.service.FileUploadService;

@RestController
@RequestMapping("admin/product")
public class FileUploadController {

    @Autowired
    FileUploadService fileUploadService;
    //http://api.gmall.com/admin/product/fileUpload
    //file
    //post

    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file) {

        String urlPath = fileUploadService.upload(file);

        return Result.build(urlPath, ResultCodeEnum.SUCCESS);
    }
}
